<template>
  <div id="sign">
    <c-title :hide="false" v-bind:text="sign_name" tolink="signrules"></c-title>
    <div class="headed">
      <div class="user">
        <div class="avatar">
          <img :src="avatar_image" alt="" />
        </div>
        <div class="userInfo">
          <span class="name">{{username}}</span>
          <span class="id">ID:&nbsp;&nbsp;{{uid}}</span>
        </div>
      </div>
      <router-link :to="fun.getUrl('signrecord')">
        <div class="record" style="margin-bottom: 0.33rem;"><span>奖励记录</span><img width="1.33rem" height="1.33rem" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/signPage/record-icon.png" alt="" /></div>
      </router-link>
    </div>
    <div class="gift-list" v-if="!sign_status" >
      <div  v-for="(item,key) in show_list" :key="key"
        style="display: inline-block; transform: rotate(-7deg); background-image: url('https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/signPage/decoration2.png'); width: 4rem; height: 4rem; background-size: cover;"
      >
        <span class="span-top" >{{item.name}}</span>
        <div class="span-bottom">{{item.total}}</div>
      </div>
    </div>
    <div><img src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/plugin/signPage/decoration1.png" class="decoration" alt="" /></div>
    <div class="sign-info">
      <div style="display: flex; justify-content: space-between; margin-left: 1rem;">
        <div class="title" v-if="!sign_status">Hi,<span style="display: inline-block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; width: 3rem; position: relative; top: 3px;">{{username}}</span>请不要忘记打卡哟!</div>
        <div class="title" v-else>Hi,今天已经{{sign_name}}成功</div>
        <router-link :to="fun.getUrl('signrules')"><div class="directions">{{sign_name}}说明></div></router-link>
      </div>
      <div class="date">{{ getDateTime() }}</div>
      <div style="display: flex; justify-content: space-between;" >
        <div style=" width: 1.5rem; height: 1.5rem; background: var(--themeBaseColor); border-radius: 100%; position: relative; right: 1.5rem;"></div>
        <div style=" width: 1.5rem; height: 1.5rem; background: var(--themeBaseColor); border-radius: 100%; position: relative; left: 1.5rem;"></div>
      </div>
      <div class="statistics">
        <div>
          <span>{{continueDays}}</span>/天
          <div>连续{{sign_name}}</div>
        </div>
        <div style="width: 0.1rem; height: 3.5rem; background-color: #e7e7e7;"></div>
        <div>
          <span>{{signTotal}}</span>/天
          <div>累计{{sign_name}}</div>
        </div>
      </div>
      <!-- <div class="btn" v-if="!sign_status" @click="signnow">立即签到</div>
      <div class="complete-btn" v-else @click="signnow">签到完成</div> -->
      <div :class="{'btn':!sign_status,'complete-btn':sign_status}"  @click="signnow">{{sign_status?`${sign_name}完成`:`立即${sign_name}`}}</div>
      <div style="display: flex; justify-content: space-around;" v-if="!sign_status">
        <div style="width: 0.5rem; height: 2rem; background: #fde6c5; position: relative; right: 3rem; border-radius: 0.83rem;"></div>
        <div style="width: 0.5rem; height: 2rem; background: #fde6c5; position: relative; left: 3rem; border-radius: 0.83rem;"></div>
      </div>
      <div style="display: flex; justify-content: space-around;" v-else>
        <div style="width: 0.5rem; height: 2rem; background: #fde6c5; position: relative; right: 3rem; border-radius: 0.83rem;"></div>
        <div style="width: 0.5rem; height: 2rem; background: #fde6c5; position: relative; left: 3rem; border-radius: 0.83rem;"></div>
      </div>
    </div>
    <!-- <div class="sign-header custom_color">
      <ul class="sign_a">
        <li class="date">{{ continue_days }}</li>
        <li class="total">连续{{ sign_name }}</li>
      </ul>
      <ul class="sign_b">
        <li class="date">{{ sign_total }}</li>
        <li class="total">累计{{ sign_name }}</li>
      </ul>
      <div class="btn" @click="signnow" :style="{lineHeight:sign_name.length>2?'1rem':'',paddingTop:sign_name.length>2?'.5rem':''}">
        {{ sign_status ? "已" + sign_name : "未" + sign_name }}
      </div>
    </div>
    <router-link :to="fun.getUrl('signrecord')">
      <div class="record">
        <span>累计{{sign_name}}奖励记录</span>
        <i class="fa fa-angle-right"></i>
      </div>
    </router-link> -->
    <date :signlog="sign_log" :signedList='sign_log'> </date>
  </div>
</template>
<script>
import member_signcontroller from "./member_signcontroller";
export default member_signcontroller;
</script>
<style lang="scss" rel="stylesheet/scss" scoped>
#sign {
  background-color: var(--themeBaseColor);
  padding: 0;
  margin: 0;
  padding-bottom: 1rem;

  .headed {
    display: flex;
    justify-content: space-between;

    .user {
      margin-top: 1.33rem;
      width: 9.86rem;
      height: 3.71rem;
      background: linear-gradient(to bottom, #fde6c5, #fff);
      border-radius: 0 5.55rem 5.55rem 0;
      display: flex;
      justify-content: center;
      align-items: center;

      .avatar img {
        max-width: 2.43rem;
        max-height: 2.43rem;
        margin-right: 0.5rem;
        border-radius: 50%;
      }

      .userInfo .name {
        display: block;
        font-weight: bold;
        text-align: left;
        color: #333;
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 5rem;
      }

      .userInfo .id {
        display: block;
        font-weight: 400;
        text-align: left;
        color: #999;
        font-size: 0.7rem;
      }
    }

    .record {
      width: 6.67rem;
      height: 2.08rem;
      padding: 0.29rem 0.57rem;
      border: 0.01rem solid #fafafa;
      margin-right: 0.75rem;
      margin-top: 2.5rem;
      border-radius: 1.67rem;
      color: #fff;
      text-align: center;
      line-height: 2rem;
      font-size: 1rem;
      display: flex;
      justify-content: center;
      align-items: center;

      img {
        width: 1.14rem;
        height: 1.14rem;
      }
    }
  }

  .gift-list {
    display: flex;
    justify-content: space-around;
    position: relative;
    top: 2rem;
    color: #fff;
    z-index: 10;

    :nth-child(1) {
      animation: bounce-down 1.6s linear infinite;
    }

    :nth-child(2) {
      animation: bounce-down 1.5s linear infinite;
    }

    :nth-child(3) {
      animation: bounce-down 1.7s linear infinite;
    }

    :nth-child(4) {
      animation: bounce-down 1.8s linear infinite;
    }

    .span-top {
      position: relative;
      bottom: 1.5rem;
      font-size: 0.5rem;
    }

    .span-bottom {
      display: block;
      position: absolute;
      top: 2.6rem;
      left: 1.2rem;
      font-size: 0.8rem;
      color: #333;
      font-weight: bold;
    }
  }

  .sign-info {
    width: 21.5625rem;
    margin-right: auto;
    margin-bottom: 0.5rem;
    margin-left: auto;
    height: 15.3rem;
    background-color: #fff;
    border-radius: 0.71rem;
    padding: 1rem;
    position: relative;

    .title {
      text-align: left;
      font-weight: bold;
      color: #333;
      font-size: 1rem;
    }

    .directions {
      position: absolute;
      right: 0;
      width: 5rem;
      height: 1.5rem;
      background-color: #000;
      opacity: 0.2;
      border-radius: 1.875rem 0 0 1.875rem;
      color: #fff;
      text-align: center;
      line-height: 1.5rem;
    }

    .date {
      text-align: left;
      color: #999;
      margin-left: 1rem;
    }

    .statistics {
      margin-top: 1rem;
      display: flex;
      justify-content: space-around;
      font-size: 0.875rem;
      color: #999;

      span {
        font-size: 2.125rem;
        font-weight: bold;
        color: #333;
      }
    }

    .complete-btn {
      width: 12rem;
      height: 3rem;
      background-color: #f84949;
      margin: 1.5rem auto 0 auto;
      border-radius: 2rem;
      color: #fff;
      font-size: 1.25rem;
      text-align: center;
      line-height: 3rem;
      opacity: 0.5;
    }

    .btn {
      width: 12rem;
      height: 3rem;
      background-color: #f84949;
      margin: 1.5rem auto 0 auto;
      border-radius: 2rem;
      color: #fff;
      font-size: 1.25rem;
      text-align: center;
      line-height: 3rem;
    }
  }

  .decoration {
    width: 3rem;
    height: 3rem;
    position: relative;
    left: 8rem;
    top: 1.5rem;
  }

  @keyframes bounce-down {
    25% {
      transform: translateY(-2px);
    }

    50%,
    100% {
      transform: translateY(2);
    }

    75% {
      transform: translateY(6px);
    }
  }
}
</style>
